package dshop.model.company;

import java.util.List;

import com.jfinal.plugin.activerecord.Record;

import appbase.jfinal.ext.BaseModel;

public class Company extends BaseModel<Company> {

	private static final long serialVersionUID = -6967680902549117464L;

	public static final Company dao = new Company();

	/**
	 * @return [{ companyName, companyAddress }]
	 */
	public static void setInfoToRs(List<Record> list, String companyIdColumn) {
		dao.mergeColumnsToRs(list, companyIdColumn, "name as companyName, address as companyAddress","companyName, companyAddress");
	}

	public static Company getCompanyInfoByAccountId(int accountId) {
		return dao.findFirst("select co.* from member_company mc LEFT JOIN company co on mc.company_id = co.id WHERE mc.account_id = "+accountId);
	}

}
